<?php $dbconnect = mysql_connect('localhost', 'root', '') or die("Couldn't connect to 'localhost' " . mysql_error() );
$dbselect = mysql_select_db('kursus_staf', $dbconnect) or die("Trouble selecting the 'kursus_staf'");
if (!function_exists('sql_val')) {
     function sql_val( $input ) {
          if ( get_magic_quotes_gpc() ) {
               $input = stripslashes( $input );
          } //get_magic_quotes_gpc()
          return ( "'" . mysql_real_escape_string( $input ) . "'" );
     }
} //end function not exist
if (!function_exists('reverb')) {
     function reverb($value) {
          return htmlspecialchars(stripslashes($value));
     }
}//end functin not exists
?> <!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Maklumat Staf Form</title>
<meta name="keywords" content="#customize#" />
<meta name="description" content="#customize#" />
<link rel="stylesheet" href="#customize#" type="text/css" />
<link rel="icon" href="#customize#" type="image/x-icon" />
<!--[if gte IE 7]><link rel="stylesheet" type="text/css" href="#customize#" media="screen, projection" /><![endif]-->
<!--[if IE 6]><link rel="stylesheet" type="text/css" href="http://universal-ie6-css.googlecode.com/files/ie6.0.3.css" media="screen, projection" /><![endif]-->
<style type="text/css">
.db_success { background-color: #91CB00; border: 1px solid #91CB00; border-radius: 5px; box-shadow: 1px 1px 0 #fff inset, -1px -1px 0 #fff inset; color: #F9F9F9; display: inline-block; margin: 10px 0; padding: 10px; }
.db_success b { background-color: #F9F9F9; border: 1px solid #F9F9F9; border-radius: 5px; box-shadow: 1px 1px 0 #91CB00 inset, -1px -1px 0 #91CB00 inset; color: #91CB00; display: inline-block; margin: 2px 0; padding: 2px; }
.db_error { background-color: #C91F2C; border: 1px solid #C91F2C; border-radius: 5px; box-shadow: 1px 1px 0 #fff inset, -1px -1px 0 #fff inset; color: #F9F9F9; display: inline-block; margin: 10px 0; padding: 10px; }
.db_error b b,.db_error b { background-color: #f6f6f6; border: 1px solid #f6f6f6; border-radius: 5px; box-shadow: 1px 1px 0 #C91F2C inset, -1px -1px 0 #C91F2C inset; color: #C91F2C; display: inline-block; margin: 2px 0; padding: 2px; }
pre { background-color: #999; border: 1px solid #999; border-radius: 5px; box-shadow: 1px 1px 0 #fff inset, -1px -1px 0 #fff inset; color: #F9F9F9; display: inline-block; margin: 10px 0; padding: 10px; text-align:left;}
pre b { background-color: #F9F9F9; border: 1px solid #F9F9F9; border-radius: 5px; box-shadow: 1px 1px 0 #999 inset, -1px -1px 0 #999 inset; color: #999; display: inline-block; margin: 2px 0; padding: 2px; }
</style>
<!-- grab 1.7.1 from google -->
<script>!window.jQuery && document.write(unescape('%3Cscript type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"%3E%3C/script%3E'));</script>

<!-- if its not online grab 1.7.1 from jquery -->
<script>!window.jQuery && document.write(unescape('%3Cscript type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"%3E%3C/script%3E'));</script>

<!-- if its not online grab latest from google -->
<script>!window.jQuery && document.write(unescape('%3Cscript type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"%3E%3C/script%3E'));</script>

<!-- if its not online grab latest from jquery -->
<script>!window.jQuery && document.write(unescape('%3Cscript type="text/javascript" src="http://code.jquery.com/jquery.min.js"%3E%3C/script%3E'));</script>

<!-- if its not online grab 1.7.1 local -->
<script>!window.jQuery && document.write(unescape('%3Cscript type="text/javascript" src="/js/jquery-1.7.1.min.js"%3E%3C/script%3E'));</script>

<!-- if its still not online your S.O.L. -->
<script>!window.jQuery && document.write(unescape('%3Cscript type="text/javascript"%3E alert("All reasonable attempts to load jQuery have failed.\\nAt this point, you may want to call it a day as\\nyou\'ve stepped in a big \'ol pile of S.O.L."); %3C/script%3E'));</script>

<!-- uncomment below to verify jQuery loaded -->
<!--script>window.jQuery && document.write(unescape('%3Cscript type="text/javascript"%3E alert("jQuery Loaded!!"); %3C/script%3E'));</script-->

<script type="text/javascript">
     $(document).ready(function() {
          $("#maklumat_staf").submit(function() {
               var str = $(this).serialize();
               $.ajax({
                    type: "POST",
                    url: "update_maklumat_staf_config.php",
                    data: str,
                    success: function(msg) {
                         $("#db_message").ajaxComplete(function(event, request, settings) {
                              $(this).replaceWith(msg); //replaces contents
                         });
                    }
               });
               return false;
          });
     });
</script>

</head>
<body id="maklumat_staf_form">
<section class="db_message" id="db_message">
<!-- your ajax message will appear here -->
</section>
<header>
<nav>
<!-- #customize# -->
</nav>
</header>
<section class="form_container">
<?php if (!isset($_POST['select'])) { 
echo '<form action="" method="POST" id="maklumat_staf_selector" name="maklumat_staf_selector" >';
echo '<fieldset>';
echo '<legend> Maklumat Staf </legend>';
echo '<select id="" name="select" class="">';
echo '<option value=""><!-- Blank --></option>';
$query = 'SELECT `id`, `nama` FROM maklumat_staf';
$result = mysql_query($query) or die('<p class="db_error"><b>A fatal MySQL error occurred while trying to save <b>'.reverb($_POST['id']).'</b> to the database.</b><br />Query: '.$query.'<br />Error: ('.mysql_errno().') '.mysql_error().'</p>');
while ($row = mysql_fetch_assoc($result)) { 
  echo '<option value="'.$row['id'].'">'.$row['nama'].'</option>';
}//end while
echo '</select>';
echo '<input type="submit" value="Submit" />';
echo '</fieldset>';
echo '</form>';
}//end if not isset
if (isset($_POST['select'])) {
$query = 'SELECT * FROM maklumat_staf WHERE `id` = '.sql_val($_POST['select']);
$result = mysql_query($query) or $db_message = '<p class="db_error"><b>A fatal MySQL error occurred while trying to save <b>'.reverb($_POST['id']).'</b> to the database.</b><br />Query: '.$query.'<br />Error: ('.mysql_errno().') '.mysql_error().'</p>';
if ($result) $db_message = '<p class="db_success">Successfully saved <b>id : '.reverb($_POST['id']).'</b> to the database!!</p>';
$result = mysql_fetch_array($result);
          if (isset($result['id'])) $id = $result['id']; else $id = "";
          if (isset($result['nama'])) $nama = $result['nama']; else $nama = "";
          if (isset($result['noic'])) $noic = $result['noic']; else $noic = "";
          if (isset($result['no_pass'])) $no_pass = $result['no_pass']; else $no_pass = "";
          if (isset($result['gred'])) $gred = $result['gred']; else $gred = "";
          if (isset($result['jawatan'])) $jawatan = $result['jawatan']; else $jawatan = "";
          if (isset($result['nama_jabatan'])) $nama_jabatan = $result['nama_jabatan']; else $nama_jabatan = "";
          if (isset($result['cawangan'])) $cawangan = $result['cawangan']; else $cawangan = "";
?>
<form action="" method="POST" id="maklumat_staf" name="maklumat_staf" >
<fieldset>
<legend> Maklumat Staf </legend>
     <label for="id">Id</label>
          <input type="number" value="<?php if (isset($id)) echo reverb($id); ?>" class="" id="" name="id" maxlength="11" min="" max="" step="" />

     <label for="nama">Nama</label>
          <input type="text" value="<?php if (isset($nama)) echo reverb($nama); ?>" class="" id="" name="nama" maxlength="255" />

     <label for="noic">Noic</label>
          <input type="text" value="<?php if (isset($noic)) echo reverb($noic); ?>" class="" id="" name="noic" maxlength="255" />

     <label for="no_pass">No Pass</label>
          <input type="text" value="<?php if (isset($no_pass)) echo reverb($no_pass); ?>" class="" id="" name="no_pass" maxlength="255" />

     <label for="gred">Gred</label>
          <input type="text" value="<?php if (isset($gred)) echo reverb($gred); ?>" class="" id="" name="gred" maxlength="255" />

     <label for="jawatan">Jawatan</label>
          <input type="text" value="<?php if (isset($jawatan)) echo reverb($jawatan); ?>" class="" id="" name="jawatan" maxlength="255" />

     <label for="nama_jabatan">Nama Jabatan</label>
          <input type="text" value="<?php if (isset($nama_jabatan)) echo reverb($nama_jabatan); ?>" class="" id="" name="nama_jabatan" maxlength="255" />

     <label for="cawangan">Cawangan</label>
          <input type="text" value="<?php if (isset($cawangan)) echo reverb($cawangan); ?>" class="" id="" name="cawangan" maxlength="255" />

<input type="submit" value="Submit" />
</fieldset>
</form>
<?php } ?>
</section>
<footer class="container">
&copy;<?php date_default_timezone_set('America/Chicago'); echo date("Y"); ?> Maklumat Staf Form <!-- #customize# -->
</footer>
</body>
</html>